package local.blueheart.data.springdatademo.domain.archive;

import lombok.Data;
import lombok.ToString;

import javax.persistence.*;
import java.util.Date;

@Entity
@Data
@ToString
@IdClass(ArchDocId.class)
public class ArchiveData {

    @Id
    @Column(length = 64)
    private String docId;

    @Id
    @Column(length = 200)
    private String dbPath;

    @Column(length = 200)
    private String serverName;

    //文档用户列表以,号分隔???
    @Column(length = 8192)
    private String users;

    //角色列表，以,号分隔???
    @Column(length = 2048)
    private String roles;

    //计算出来的链接地址
    private String url;

    //正文，有可以保存
    private String content;

    //标题
    private String title;

    //创建者
    @Column(length = 100)
    private String creator;

    //文号
    @Column(length = 100)
    private String fileNo;

    @Version
    private Integer version;

    private Date dateCreated;

    private Date lastUpdated;

    @PreUpdate
    @PrePersist
    public void updateTimeStamps() {
        lastUpdated = new Date();
        if (dateCreated==null) {
            dateCreated = new Date();
        }
    }
}
